import { modal } from 'vue-strap'
import { showMsg, importPortfolioTag } from '../../../vuex/action'

export default {
  name: 'ImportTag',
  components: {
    'vue-modal': modal
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xImportTag: importPortfolioTag
    }
  },
  data() {
    return {
      showModal: false
    }
  },
  methods: {
    submit() {
      var file = this.$els.file.files[0]
      if (!file) {
        return this.xShowMsg({
          type: 'danger',
          content: '请先选择Excel文件'
        })
      }
      var data = new FormData()
      data.append('excelFile', file)
      this.xImportTag(data)
        .then((res) => {
          this.showMsg = false
          this.showModal = false
          this.$els.form.reset()
        })
        .catch((res) => {
            this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  }
}
